package java_thinking.unit_18_IO._18_13;

import nu.xom.*;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @Desc:   从XML中反序列化Person对象
 * @author: cww
 * @DateTime: 2019-05-19 15:15
 */

public class People extends ArrayList<Person> {
    static String file = "/Code/spring-root/src/maindemo/java/java_thinking/unit_18_IO/_18_13/";
    public People(String fileName) throws ParsingException, IOException {
        Document doc = new Builder().build(fileName);
        Elements elements = doc.getRootElement().getChildElements();
        for (int i = 0; i < elements.size(); i++) {
            add(new Person(elements.get(i)));
        }
    }

    public static void main(String[] args) throws ParsingException, IOException {
        People people = new People(file + "PersonXML.xml");
        System.out.println(people);
    }
}
